How to find next (by a single parameter) element in c++? (stl) [closed]

Posted by user2136963 on Stack Overflow See other posts from Stack Overflow or by user2136963
Published on 2013-10-08T09:52:31Z Indexed on 2013/10/19 9:55 UTC
Read the original article Hit count: 88

Filed under:
|

I have n humans of THuman class

Each human has scored some points in one of two rounds. (score1 and score2)

Each human has its unique id. Score1 and 2 are also unique.

Besides, a human has a score_t=score1+score2, which can be the same for two of them.

I need to implement 6 variables to THuman which return id of a human with:

  1. bigger score1
  2. smaller score1
  3. bigger score2
  4. smaller score2
  5. bigger score_t
  6. smaller score_t

(if there are many humans those satisfy theese conditions, the one with smallest difference of corresponding parameter should be chosen (like score1 for 1 and 2))

In other words, it's some kind of storing 3 human sortings.

Two more functions I need should get argument x, set score1 or score 2 to x, and then refresh some of the 6 variables above.

If I needed sorting by only one variable, I would simply create set and defined > and < operators for my class. But what is the solution for three of parameters? Is it possible to use STL here, or I should create my own lists/treaps?

__ Answer: How to update set of pointers c++?

© Stack Overflow or respective owner

Related posts about c++

Related posts about stl